<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
   <script type="text/javascript" src="${approot}/res/jquery/tablecloth/tablecloth.js"></script>
   <link href="${approot}/res/jquery/tablecloth/tablecloth.css" type="text/css" rel="stylesheet">
</head>
  <style type="text/css">
  body {
  font-size: 62.5%;
  } //这个样式，控制ui的展示大小，否则，会显示很大
  </style> 

<body>
    <script type="text/javascript">
	$(function() {
		$("#tabs").tabs();
	});
	
	function save_category(jsons){
	       $.ajax({
		   	url:'${approot}admin/cms/category/add',
		   	dataType: 'json',
		   	contentType: 'application/json',
			data:jsons,
			type:'post',
			beforeSend:function(){
			  // $('#main').disabled='true';
			},
			error:function(request){
				alert(request.responseText);
			},
			success:function(data){
			   alert("子栏目添加成功");
			   //刷新树
			   parent.frames['tree'].location.reload();
			   location.reload();
			}
		   });
	}
	function update_category(jsons){
	       $.ajax({
		   	url:'${approot}admin/cms/category/update',
		   	dataType: 'json',
		   	contentType: 'application/json',
			data:jsons,
			type:'post',
			beforeSend:function(){
			  // $('#main').disabled='true';
			},
			error:function(request){
				alert(request.responseText);
			},
			success:function(data){
			   alert("栏目修改成功");
			   //刷新树
			   parent.frames['tree'].location.reload();
			   location.reload();
			}
		   });
	}
	
    function doSave()
    {   
        var str=$('#add_category').serializeObject();
        var jsons = $.toJSON(str);
        save_category(jsons);
    }
    function doUpdate()
    {   
        var str=$('#edit_category').serializeObject();
        var jsons = $.toJSON(str);
        update_category(jsons);
    }
	
	</script>


  <div id="tabs">
    
    <c:if test="${level==0}">
	<ul>
		<li><a href="#tabs-1">子菜单</a></li>
	</ul>
	<div id="tabs-1">
	
	  <a href="${approot}menu/create/${fid}">添加子菜单</a>
	  
	  <div class="table">
                    <table id="js_data_source">
                    <tr>
                        <th width="12%">ID</th>
                        <th>菜单名称</th>
                        <th width="15%">菜单类型</th>
                        <th width="12%">菜单级别</th>
                        <th width="12%">动作Id</th>
                        <th width="12%">菜单排序</th>
                        <th width="12%">操作</th>
                    </tr>
                  <c:forEach var="menu" items="${menus}" varStatus="stat">
                   <tr>
                        <td>${menu.menuid }</td>
                        <td>${menu.menuname }</td>
                        <td>
                         <c:if test="${menu.menutype==1}">有子菜单</c:if>
                         <c:if test="${menu.menutype==2}">无子菜单</c:if>
                         <c:if test="${menu.menutype==3}">分割线</c:if>
                        </td>
                        <td>${menu.levels }</td>
                        <td>
                        <c:if test="${menu.actionid==0}">无</c:if>
                        <c:if test="${menu.actionid!=0}"> ${menu.actionid}</c:if>
                        </td>
                       
                         <td>
                          <c:choose>
                          <c:when test="${stat.first}"> <a href="${approot}menu/sortdown/${menu.menuid}">下移</a></c:when>
                          <c:when test="${stat.last}"> <a href="${approot}menu/sortup/${menu.menuid}">上移</a></c:when>
                          <c:otherwise>
                            <a href="${approot}menu/sortup/${menu.menuid}">上移</a>
                            <a href="${approot}menu/sortdown/${menu.menuid}">下移</a>
                          </c:otherwise>
                          </c:choose>
                         </td>
                        
                        <td>
                        <a href="${approot}menu/edit/${menu.menuid}">修改</a>
                        <a href="${approot}menu/delete/${menu.menuid}" onclick="return confirm('确定删除?');">删除</a>
                        <a href="${approot}menu/edit/${menu.menuid}">移动</a>
                        </td>
                    </tr>
                   </c:forEach>  
                   </table>
         </div>
    </div>			
    </c:if>
    
    
    
    <c:if test="${level==1}">
	<ul>
		<li><a href="#tabs-1">子菜单</a></li>
	</ul>
	<div id="tabs-1">
	  <a href="${approot}menu/create/${fid}">添加子菜单</a>
	 <div class="table">
                    <table id="js_data_source">
                    <tr>
                        <th width="12%">ID</th>
                        <th>菜单名称</th>
                        <th width="15%">菜单类型</th>
                        <th width="12%">菜单级别</th>
                        <th width="12%">动作Id</th>
                        <th width="12%">菜单排序</th>
                        <th width="12%">操作</th>
                    </tr>
                  <c:forEach var="menu" items="${menus}" varStatus="stat">
                   <tr>
                        <td>${menu.menuid }</td>
                        <td>${menu.menuname }</td>
                        <td>
                         <c:if test="${menu.menutype==1}">有子菜单</c:if>
                         <c:if test="${menu.menutype==2}">无子菜单</c:if>
                         <c:if test="${menu.menutype==3}">分割线</c:if>
                       </td>
                        <td>${menu.levels }</td>
                         <td>
                        <c:if test="${menu.actionid==0}">无</c:if>
                        <c:if test="${menu.actionid!=0}"> ${menu.actionid}</c:if>
                        </td>
                         <td>
                            <c:choose>
                          <c:when test="${stat.first}"> <a href="${approot}menu/sortdown/${menu.menuid}">下移</a></c:when>
                          <c:when test="${stat.last}"> <a href="${approot}menu/sortup/${menu.menuid}">上移</a></c:when>
                          <c:otherwise>
                            <a href="${approot}menu/sortup/${menu.menuid}">上移</a>
                            <a href="${approot}menu/sortdown/${menu.menuid}">下移</a>
                          </c:otherwise>
                          </c:choose>
                        </td>
                        <td>
                        
                        <a href="${approot}menu/edit/${menu.menuid}">修改</a>
                        <a href="${approot}menu/delete/${menu.menuid}" onclick="return confirm('确定删除?');">删除</a>
                        <a href="${approot}menu/edit/${menu.menuid}">移动</a>
                        
                        </td>
                    </tr>
                   </c:forEach>  
                   </table>
         </div>
    </div>			
    </c:if>
    
    
    <c:if test="${level==2}">
	<ul>
		<li><a href="#tabs-1">动作列表</a></li>
	</ul>
	<div id="tabs-1">
	 <a href="${approot}action/create/${fid}">添加动作</a>
	 <div class="table">
                    <table id="js_data_source">
                    <tr>
                        <th width="12%">ID</th>
                        <th width="20%">动作名称</th>
                        <th>动作URL</th>
                        <th width="15%">动作类型</th>
                        <th width="12%">动作图标</th>
                        <th width="12%">操作</th>
                    </tr>
                  <c:forEach var="action" items="${actions}">
                   <tr>
                        <td>${action.actionid }</td>
                        <td>${action.actionname }</td>
                        <td>${action.actioncode }</td>
                        <td>
                         <c:if test="${action.actiontype==1}"><font color='red'>授权动作</font></c:if>
                         <c:if test="${action.actiontype==2}">普通动作</c:if>
                         <c:if test="${action.actiontype==3}"><font color='red'>密码动作</font></c:if>
                       </td>
                        <td>
                         <c:if test="${menu.imgsrc==null}">无</c:if>
                        <c:if test="${menu.imgsrc!=null}">${action.imgsrc}</c:if>
                        </td>
                        <td>
                        
                        <a href="${approot}action/edit/${action.actionid}">修改</a>
                        <a href="${approot}action/delete/${action.actionid}" onclick="return confirm('确定删除?');">删除</a>
                        
                        </td>
                    </tr>
                   </c:forEach>  
                   </table>
         </div>
	
    </div>			
    </c:if>

	

</div>

</body>
</html>
